// 解析飞行数据
export const parseFlightData = (rawData) => {
    const lines = rawData.trim().split('\n')
    return lines.map(line => {
        const parts = line.trim().split(' ')
        const data = {}

        parts.forEach(part => {
            const [key, value] = part.split('=')
            if (key && value !== undefined) {
                // 转换数字类型
                data[key] = isNaN(value) ? value : parseFloat(value)
            }else{
                data['time'] = Number(part)
            }
        })

        return {
            time: data.time,
            stage: data.stage,
            position: {
                lon: data.lon,
                lat: data.lat,
                hei: data.hei
            },
            attitude: {
                head: data.head,
                elev: data.elev,
                roll: data.roll
            },
            velocity: {
                vel: data.vel,
                vx: data.vx,
                vy: data.vy,
                vz: data.vz
            },
            ins: {
                x: data.insX,
                y: data.insY,
                z: data.insZ
            },
            raw: line // 保留原始数据
        }
    })
}